package com.mirror.llk.utils;

/**
 * 1.NULL：空值。 2.INTEGER：带符号的整型，具体取决有存入数字的范围大小。 3.REAL：浮点数字，存储为8-byte IEEE浮点数。
 * 4.TEXT：字符串文本。 5.BLOB：二进制对象。
 */
public class Sql {

	public enum CREATE {
		;

		public static String THEME;

		static {
			StringBuffer sql = new StringBuffer();
			sql.append("CREATE TABLE IF NOT EXISTS T_LLK_THEME ");
			sql.append("  (ID INTEGER, ");
			sql.append("   LOCAL_ID INTEGER PRIMARY KEY AUTOINCREMENT, ");
			sql.append("   THEME_NAME VARCHAR(50), ");
			sql.append("   THEME_DESC VARCHAR(255), ");
			sql.append("   THEME_TYPE INTEGER, ");
			sql.append("   THEME_DOWNLOAD INTEGER); ");
			THEME = sql.toString();
		}

		public static String THEME_HISTORY;

		static {
			StringBuilder sql = new StringBuilder();
			sql.append("CREATE TABLE IF NOT EXISTS T_LLK_THEME_HISTORY (");
			sql.append("  ID INTEGER PRIMARY KEY AUTOINCREMENT,");
			sql.append("  THEME_ID INTEGER,");// 主题ID
			sql.append("  THEME_TYPE INTEGER,");// 主题类型 1-官方 2-网友分享
			sql.append("  TOTAL_TIME INTEGER,");// 总共时间
			sql.append("  REMAINING_TIME INTEGER,");// 剩余时间
			sql.append("  INT_ARRAY VARCHAR(500),");// 二维数组
			sql.append("  PROMPT_TIMES INTEGER,");// 提醒次数
			sql.append("  RESET_TIMES INTEGER,");// 洗牌次数
			sql.append("  CREATE_TIME VARCHAR(20),");// 存档时间
			sql.append("  GAME_LEVEL INTEGER");// 关卡
			sql.append(")");
			THEME_HISTORY = sql.toString();
		}
	};

	public enum INSERT {
		;

		public static String THEME;

		static {
			StringBuffer sql = new StringBuffer();
			sql.append("INSERT INTO T_LLK_THEME ");
			sql.append("  (ID, THEME_NAME, THEME_DESC, THEME_TYPE, THEME_DOWNLOAD) ");
			sql.append("VALUES ");
			sql.append("  (?, ?, ?, ?, ?) ");
			THEME = sql.toString();
		}

		public static String THEME_HISTORY;

		static {
			StringBuilder sql = new StringBuilder();
			sql.append("INSERT INTO T_LLK_THEME_HISTORY ");
			sql.append("  (ID, ");
			sql.append("   THEME_ID, ");
			sql.append("   THEME_TYPE, ");
			sql.append("   TOTAL_TIME, ");
			sql.append("   REMAINING_TIME, ");
			sql.append("   INT_ARRAY, ");
			sql.append("   PROMPT_TIMES, ");
			sql.append("   RESET_TIMES, ");
			sql.append("   GAME_LEVEL, ");
			sql.append("   CREATE_TIME) ");
			sql.append("VALUES ");
			sql.append("  (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ");
			THEME_HISTORY = sql.toString();
		}
	}

	public enum SELECT {
		;
		public static String THEME_LOCAL;
		static {
			StringBuffer sql = new StringBuffer();
			sql.append("SELECT THEME_NAME, THEME_DESC, THEME_TYPE, THEME_DOWNLOAD ");
			sql.append("  FROM T_LLK_THEME ");
			sql.append(" WHERE LOCAL_ID = ? ");
			THEME_LOCAL = sql.toString();
		}

		public static String THEME_IDS = "SELECT ID FROM T_LLK_THEME";

		public static String THEME_LIST;
		static {
			StringBuffer sql = new StringBuffer();
			sql.append("SELECT ID, LOCAL_ID, THEME_NAME, THEME_DESC, THEME_TYPE, THEME_DOWNLOAD ");
			sql.append("  FROM T_LLK_THEME ");
			sql.append(" ORDER BY LOCAL_ID DESC LIMIT ? OFFSET ? ");
			THEME_LIST = sql.toString();
		}

		public static String THEME_MAX_LOCAL_ID = "SELECT MAX(LOCAL_ID) FROM T_LLK_THEME";

		public static String THEME_HISTORY;

		static {
			StringBuilder sql = new StringBuilder();
			sql.append("SELECT ID, ");
			sql.append("       THEME_ID, ");
			sql.append("       THEME_TYPE, ");
			sql.append("       TOTAL_TIME, ");
			sql.append("       REMAINING_TIME, ");
			sql.append("       INT_ARRAY, ");
			sql.append("       PROMPT_TIMES, ");
			sql.append("       RESET_TIMES, ");
			sql.append("       GAME_LEVEL, ");
			sql.append("       CREATE_TIME ");
			sql.append("  FROM T_LLK_THEME_HISTORY ");
			sql.append(" WHERE ID = ? ");
			THEME_HISTORY = sql.toString();
		}

		public static String THEME_HISTORY_LIST;

		static {
			StringBuilder sql = new StringBuilder();
			sql.append("SELECT ID, ");
			sql.append("       THEME_ID, ");
			sql.append("       THEME_TYPE, ");
			sql.append("       TOTAL_TIME, ");
			sql.append("       REMAINING_TIME, ");
			sql.append("       INT_ARRAY, ");
			sql.append("       PROMPT_TIMES, ");
			sql.append("       RESET_TIMES, ");
			sql.append("       GAME_LEVEL, ");
			sql.append("       CREATE_TIME ");
			sql.append("  FROM T_LLK_THEME_HISTORY ");
			sql.append(" ORDER BY CREATE_TIME DESC ");
			THEME_HISTORY_LIST = sql.toString();
		}
	}

	public enum UPDATE {
		;

		public static String THEME_DOWNLOAD = "UPDATE T_LLK_THEME SET THEME_DOWNLOAD = ? WHERE ID = ?";
	}

	public enum DELETE {
		;

		public static String LOCAL_THEME = "DELETE FROM T_LLK_THEME WHERE LOCAL_ID = ?";

	}

	public enum DROP {
		;

		public static String THEME = "DROP TABLE T_LLK_THEME";

	}
}
